


$.extend({
	loadLogin:function(){
		var loginHtml = $(".main-form").html();
		var old = $("body").html();
		$("#reg").click(function(){
			$("body").css("background-image","url(static/ssjf/img/bg/bg_orange.png)");
			var select = '<div class="container" id="header" style="background-color: #fff;"><div class="row title">';
			select += '<div class="col-1 col-sm-1 col-back"><img src="static/ssjf/img/symbol/back_arrow_b.png"></div>';
			select += '<div class="col-10 col-sm-10 black">选择</div><div class="col-1 col-sm-1"></div></div></div>';
			select += '<div id="select"><div class="row"><img height="280px" src="static/ssjf/img/banner/banner01.png">';
			select += '<div class="row"><div class="col-12"><div class="img_max"><img src="static/ssjf/img/select01.png"></div></div>';
			select += '<div class="col-12 select_btn btn-needer"><div>我有融资需求</div></div></div></div>';
			select += '<div class="row"><img height="280px" src="static/ssjf/img/banner/banner02.png"><div class="row">';
			select += '<div class="col-12"><div class="img_max"><img src="static/ssjf/img/select02.png"></div></div>';
			select += '<div class="col-12 select_btn btn-giver"><div>我是金融机构</div></div></div></div></div>';
			$("body").empty();
			$("body").append(select);
			$(".btn-needer").click(function(){
				$.loadReg(old,loginHtml,'000002');
			});
			$(".btn-giver").click(function(){
				$.loadReg(old,loginHtml,'000001');
			});
			$(".col-back img").click(function(){
				$("body").css("background-image","inherit");
				$("body").empty();
				$("body").append(old);
				$.loadLogin();
			});
		});
		$("#log").click(function (){
			$.loadTringle(loginHtml,false);
		});
		$(".login-btn").click(function(){
			var name = $("input[name='account']").val();
			var pass = $("input[name='password']").val();
			$.post("ssjf/user/login",{account:name,password:pass},function(result){
				result = eval("(" + result + ")");
				if(result.res == 1){
					location.href = "ssjf/index.html";
				}else{
					$(".res-msg").text(result.resMsg);
				}
			});
		});
	},
	loadReg:function(old,loginHtml,type){
		$("body").css("background-image","inherit");
		$("body").empty();
		$("body").append(old);
		var regHtml = "<div class=\"row\">";
		regHtml += "	<div class=\"col-12 padding0\">";
		regHtml += "		<input type=\"text\" class=\"login-number\" name=\"tel\" placeholder=\"手机号码\">";
		regHtml += "	</div>";
		regHtml += "	<div class=\"col-12 padding0\">";
		regHtml += "		<input type=\"text\" class=\"login-user\" name=\"account\" placeholder=\"用户名\">";
		regHtml += "	</div>";
		regHtml += "	<div class=\"col-12 padding0\">";
		regHtml += "		<input type=\"password\" class=\"login-pass\" name=\"password\" placeholder=\"密码\">";
		regHtml += "	</div>";
		regHtml += "</div>";
		regHtml += "<div class=\"row\">";
		regHtml += '	<div class="col-12 res-msg"></div>';
		regHtml += "	<div class=\"col-12 login-submit reg-btn\">注册</div>";
		regHtml += "</div>";
		regHtml += "<div class=\"row center margin-tb-2r\">";
		regHtml += "	<div class=\"col-12\"><span class=\"color-999797\">已经注册了吗？</span><span class=\"color-E66436 return-to\" >请登录</span></div>";
		regHtml += "</div>";
		$.loadTringle(regHtml,true);
		$("#log").click(function (){
			$.loadTringle(loginHtml,false);
		});
		$(".login-btn").click(function(){
			var name = $("input[name='account']").val();
			var pass = $("input[name='password']").val();
			$.post("ssjf/user/login",{account:name,password:pass},function(result){
				result = eval("(" + result + ")");
				if(result.res == 1){
					location.href = "ssjf/index.html";
				}else{
					$(".res-msg").text(result.resMsg);
				}
			});
		});
		$(".return-to").click(function(){
			$.loadTringle(loginHtml,false);
			$.loadLogin();
		});
		$(".reg-btn").click(function(){
			var telNum = $("input[name='tel']").val();
			var name = $("input[name='account']").val();
			var pass = $("input[name='password']").val();
			$.post("ssjf/user/reg.dat",{telephone:telNum,account:name,password:pass,userTypeId:type},function(result){
				result = eval("(" + result + ")");
				if(result.res == 1){
					location.href = "ssjf/page/login.html";
				}else{
					$(".res-msg").text(result.resMsg);
				}
			});
		});
	},
	loadTringle:function(htmlContent,isLeft){
		var triangleHtml;
		if(isLeft){ 
			triangleHtml = "<div class=\"col-6\"><img src=\"static/ssjf/img/triangle.png\"></div>";
			triangleHtml += "<div class=\"col-6\"></div>"
		}else{
			triangleHtml = "<div class=\"col-6\"></div>";
			triangleHtml += "<div class=\"col-6\"><img src=\"static/ssjf/img/triangle.png\"></div>";
		}
		$(".triangle").html(triangleHtml);
		$(".main-form").html(htmlContent);
	}
});
$(function(){
	$.loadLogin();
});

